package drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.branch_transaction_register;

import drds.global_transaction.api.message_codec.Message;
import drds.global_transaction.api.message_codec.request_and_response.transaction.TransactionResponse;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;
import java.nio.ByteBuffer;

public class BranchTransactionRegisterResponseMessage extends TransactionResponse implements Serializable
{

	private static final long serialVersionUID = 1L;
	@Setter
	@Getter
	private long globalTransactionId;
	@Setter
	@Getter
	private long branchTransactionId;

	@Override
	public void decode(ByteBuffer byteBuffer)
	{
		super.decode(byteBuffer);
		this.globalTransactionId = byteBuffer.getLong();
		this.branchTransactionId = byteBuffer.getLong();
	}

	@Override
	public short getTypeCode()
	{
		return Message.branch_transaction_register_response_message;
	}

	@Override
	public ByteBuffer putBytesToByteBuffer()
	{
		ByteBuffer byteBuffer = super.putBytesToByteBuffer();
		byteBuffer.putLong(globalTransactionId);
		byteBuffer.putLong(branchTransactionId);
		markAsEncode();
		return byteBuffer;

	}
}
